#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

void solve()
{
    int n, k;
    cin >> n >> k;
    priority_queue<int, vector<int>, less<int>> pq;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        pq.push(x);
    }
    int ans = pq.top();
    pq.pop();
    while(pq.size()){
        if(ans + pq.top() > k) {
            cout << k - ans << endl;
            return;
        }
        ans += pq.top();
        pq.pop();
    }
    cout << k - ans << endl;
}

int main()
{
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}